package com.bincky.pageobject;

import com.bincky.common.BasePage;
import org.openqa.selenium.By;

/**
 * 描述:
 *
 * @author Bincky Liang
 * @date 2021-02-08 11:57:53
 */

public class LoginPage extends BasePage {

    //用private是封装的概念，外部不能直接访问，只能通过get和set进行访问

    //用户名输入框
    private By usernameBy = By.name("username");

    //密码输入框
    private By passwordBy = By.name("password");

    //登录按钮
    private By loginButtonBy = By.xpath("//span[contains(text(),'登 录')]");

    //错误提示
    private By errorTipsBy = By.xpath("//div[contains(@class,'el-message el-message--error')]");

    /**
     * 清空用户名元素的值
     */
    public void clearUsername(){
        clear(usernameBy);
    }

    /**
     * 输入用户名
     */
    public void inputUsername(String data){
        type(usernameBy,data);
    }

    /**
     * 清空密码元素的值
     */
    public void clearPassword(){
        clear(passwordBy);
    }

    /**
     * 输入密码
     */
    public void inputPassword(String data){
        type(passwordBy, data);
    }

    /**
     * 点击登录按钮
     */
    public void clickLoginButton(){
        click(loginButtonBy);
    }

    /**
     * 获取错误提示的文本
     */
    public String getErrorTipsText(){
        return getText(errorTipsBy);
    }


}
